//
//  ProfileEditNameViewModel.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 13.04.25.
//

import Foundation
class ProfileEditGenderViewModel : KoiAccountingBaseViewModel {
    
    @Published var state = ""
    
    @Published var isLoading = false
    
    func genderModify(gender: Int) {
        isLoading = true
        KoiAccountingNetApi.standard.sexModify(sex: gender) { result in
            switch result {
            case .success:
                self.isLoading = false
                KoiAccountingUserManager.standard.updateUser(gender: gender)
                self.state = "success"
            case .failure(let failure):
                self.isLoading = false
                self.state = failure.netErrorMsg()
                logger.error("genderModify fail \(failure)")
            }
        }
    }
}
